package demo;

import org.apache.commons.httpclient.DefaultHttpMethodRetryHandler;
import org.apache.commons.httpclient.HttpClient;
import org.apache.commons.httpclient.NameValuePair;
import org.apache.commons.httpclient.methods.PostMethod;
import org.apache.commons.httpclient.params.HttpMethodParams;

public class Call {
	public static void main(String[] args) throws Exception {
		String url = "http://www.hn12396.com/authSSO.jhtml";
		PostMethod postMethod = null;
//		String result = "";

		HttpClient httpClient = new HttpClient();
		postMethod = new PostMethod(url);
		// NameValuePair[] data = { new NameValuePair("fid",
		// URLEncoder.encode(URLEncoder.encode(sendMessage.getFid()+"","utf-8"))),
		// new NameValuePair("sortid", URLEncoder.encode(URLEncoder.encode(sendMessage.getSortid()+"","utf-8"))),
		// new NameValuePair("subject", URLEncoder.encode(URLEncoder.encode(sendMessage.getSubject()+"","utf-8"))),
		// new NameValuePair("message", URLEncoder.encode(URLEncoder.encode(sendMessage.getMessage()+"","utf-8")))
		// };
		NameValuePair[] data = { new NameValuePair("username", "lin"), new NameValuePair("password", "@lin10"),
				new NameValuePair("password", "@lin10") };

		postMethod.setRequestBody(data);
		postMethod.addRequestHeader("Content-Type", "text/html;charset=UTF-8");

		postMethod.getParams().setParameter(HttpMethodParams.RETRY_HANDLER, new DefaultHttpMethodRetryHandler());
		postMethod.setFollowRedirects(false);
		httpClient.executeMethod(postMethod);

		// byte[] responseBody = postMethod.getResponseBody();
		String string = postMethod.getResponseBodyAsString();
		System.out.println(string);

	}
}